//
//  MainViewController.swift
//  DSwb
//
//  Created by Mac on 2017/2/11.
//  Copyright © 2017年 com.lanlian. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad(){
        super.viewDidLoad()
        
        addChildViewController(HomeViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileViewController(), title: "我", imageName: "tabbar_profile")
        
    }
    
    //swift中支持方法的重载  oc中不能有相同的方法名
    private func addChildViewController(childVc: UIViewController, title: String, imageName: String) {
        //1.创建子控制器
        //2.设置子控制器的属性
        childVc.title = title
        childVc.tabBarItem.image = UIImage(named: imageName)
        childVc.tabBarItem.image = UIImage(named: imageName + "_highlighted")
        //3.包装导航栏控制器
        let childNav = UINavigationController(rootViewController: childVc)
        //4.添加控制器
        addChildViewController(childNav)

    }
}
